//
//  CAOrderDoneView.m
//  LNH
//
//  Created by twentylx on 2018/2/21.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAOrderDoneView.h"

@implementation CAOrderDoneView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.logoImageView];
    [self addSubview:self.tipsLabel];
    [self addSubview:self.homeButton];
    [self addSubview:self.orderButton];
}

- (void)updateConstraints {
    [super updateConstraints];
    
    [_logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo((SCREEN_WIDTH-140)/2);
        make.top.equalTo(self).offset(80);
        make.right.mas_equalTo(-(SCREEN_WIDTH-140)/2);
        make.height.mas_equalTo(140);
    }];
    
    [_tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo((SCREEN_WIDTH-250)/2);
        make.top.equalTo(self).offset(250);
        make.left.mas_equalTo((SCREEN_WIDTH-250)/2);
        make.width.mas_equalTo(250);
    }];

    [_homeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.tipsLabel);
        make.top.equalTo(self.tipsLabel.mas_bottom).offset(30);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(30);
    }];

    [_orderButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.tipsLabel);
        make.top.equalTo(self.homeButton);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(30);
    }];
}

#pragma mark get & set
- (UIImageView *)logoImageView {
    if (!_logoImageView) {
        _logoImageView = [UIImageView new];
        _logoImageView.image = LMImageNamed(@"orderDone");
        _logoImageView.layer.cornerRadius = 10;
    }
    return _logoImageView;
}

- (UILabel *)tipsLabel {
    if (!_tipsLabel) {
        _tipsLabel = [UILabel new];
        _tipsLabel.text = @"恭喜您，订单已支付成功！";
        _tipsLabel.textColor = RGBCOLOR(241, 90, 36);
        _tipsLabel.font = [UIFont systemFontOfSize:18];
        _tipsLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _tipsLabel;
}

- (UIButton *)homeButton {
    if (!_homeButton) {
        _homeButton = [UIButton new];
        [_homeButton setTitle:@"返回首页" forState:UIControlStateNormal];
        [_homeButton setTitleColor:RGBCOLOR(241, 90, 36) forState:UIControlStateNormal];
        _homeButton.layer.borderColor = [RGBCOLOR(241, 90, 36) CGColor];
        _homeButton.layer.borderWidth = 1;
        _homeButton.layer.cornerRadius = 5;
        _homeButton.titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _homeButton;
}

- (UIButton *)orderButton {
    if (!_orderButton) {
        _orderButton = [UIButton new];
        [_orderButton setTitle:@"查看订单" forState:UIControlStateNormal];
        [_orderButton setTitleColor:RGBCOLOR(241, 90, 36) forState:UIControlStateNormal];
        _orderButton.layer.borderColor = [RGBCOLOR(241, 90, 36) CGColor];
        _orderButton.layer.borderWidth = 1;
        _orderButton.layer.cornerRadius = 5;
        _orderButton.titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _orderButton;
}

@end
